<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
	var path = window.document.location.href;
	var pathName = window.document.location.pathname;
	var hostPath = path.substring(0, path.indexOf(pathName));
	var projectName = pathName
			.substring(0, pathName.substr(1).indexOf("/") + 1);
	document
			.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
</script>
</head>
<body>
	<form method="post" id="fm">
		<table style="width: auto; height: auto" fitColumns="true">
			<tr>
				<td>业务编号</td>
				<td><input id="businessKey" name="businessKey" class="easyui-validatebox" required="true" readonly="true">&nbsp;</td>
			</tr>
			<tr>
				<td>流程实例号</td>
				<td><input id='procInstId' name='procInstId' class='easyui-validatebox' required='true' readonly="true">&nbsp;</td>
			</tr>
			<tr>
				<td>任务号</td>
				<td><input id='taskId' name='taskId' class='easyui-validatebox'	required='true' readonly="true">&nbsp;</td>
			</tr>
			<tr>
				<td>处理结果</td>
				<td><select id='result' name='result' class='easyui-combobox' style="width:150px">
						<option value="同意">同意</option>
						<option value="不同意">不同意</option>
						<option value="拒绝">拒绝</option>
						<option value="无关">无关</option>
					</select>				
				&nbsp;
				</td>
			</tr>
			<tr>
				<td>下一处理人</td>
				<td><input id='handleUser' name='handleUser' class='easyui-validatebox'>&nbsp;</td>
			</tr>
			<tr>
				<td>处理意见</td>
				<td><input id='comments' name='comments' class='easyui-textbox' data-options="multiline:true" style="height:100px;width:150px">&nbsp;</td>
			</tr>
		</table>
	</form>
	<div id="dg-buttons">
		<a href="javascript:dowork()" class="easyui-linkbutton"
			iconCls="icon-ok">提交</a>
	</div>
	<script type="text/javascript">
		$(document).ready(function() {
			var procInstId = getParam('procInstId');
			var taskId = getParam('taskId');
			var taskDefKey = getParam('taskDefKey');
			var businessKey = getParam('businessKey');
			$('#businessKey').val(businessKey);
			$('#procInstId').val(procInstId);
			$('#taskId').val(taskId);
		});

		function dowork() {
			$.messager.progress();
			$.ajax({
				type : "POST",
				dataType : "json",
				contentType : "application/json;charset=utf-8",
				url : projectName + "/workflow/task/dowork",
				data : JSON.stringify($("#fm input").serializeObject()),
				beforeSend : function() {
					var isValid = $("#fm").form("validate")
					if (!isValid) {
						$.messager.progress("close");
						$.messager.alert("系统提示", "表单验证不通过！");
					}
					return isValid;
				},
				success : function(result) {
					$.messager.progress("close");
					if (result.success) {
						$.messager.alert("系统提示", "提交成功！");
						debugger;
						resetFromValue();
						$("#win").dialog("close");
					} else {
						if (!jQuery.isEmptyObject(result.message)) {
							$.messager.alert("系统错误", result.message);
						} else {
							$.messager.alert("系统错误", result);
						}
						return;
					}
				},
				error : function(err, status) {
					errorMsgAlert(err);
					$.messager.progress("close");
				}
			});
		}

		//获取URL参数
		function getParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return decodeURI(r[2]);
			return null;
		}
	</script>
</body>
</html>

